package oop.day03.HomeWork1;

public class PolymorphicDemo
{
    public static void main(String[] args)
    {
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("huang",1,"yellow");
        animals[1] = new Dog("big Black",2,"black");
        animals[2] = new Fish("Lei Lei",2,"gold");
        animals[3] = new Chick("Cai Xu Kun",225,"gray");
        animals[4] = new Chick("Kun Kun",225,"gray");

        for (int i = 0; i < animals.length; i++)
        {
            System.out.println("animal name = " + animals[i].name);

            if(animals[i] instanceof Dog)
            {
                Dog dog = (Dog)animals[i];
                dog.lookHome();
            }
            if(animals[i] instanceof Chick)
            {
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }
            if(animals[i] instanceof Swim)
            {
                Swim swim = (Swim)animals[i];
                swim.swim();
            }
        }
        // 喂动物
        Master master = new Master();
        for (Animal a :
                animals)
        {
            master.feed(a);
        }
    }





}
